package com.example.hotelmanagement.service;

import com.example.hotelmanagement.entity.Booking;
import com.example.hotelmanagement.mapper.BookingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookingService {

    @Autowired
    private BookingMapper bookingMapper;

    // 获取所有预订
    public List<Booking> getAllBookings() {
        return bookingMapper.getAllBookings();
    }

    // 根据 ID 获取单个预订
    public Booking getBookingById(Long id) {
        return bookingMapper.getBookingById(id);
    }

    // 创建新预订
    public void createBooking(Booking booking) {
        bookingMapper.insertBooking(booking);
    }

    // 更新预订（接受 Long id 和 Booking booking）
    public void updateBooking(Long id, Booking booking) {
        // 设置 ID
        booking.setId(id);
        // 执行更新操作
        bookingMapper.updateBooking(booking);
    }

    // 删除预订
    public void deleteBooking(Long id) {
        bookingMapper.deleteBooking(id);
    }
}
